import json
import os

# 项目根路径
BASEDIR = os.path.dirname(os.path.dirname(__file__))
# 获取当前文件的绝对路径
# FILE_DIR = os.path.abspath(__file__)
# BASEDIR = os.path.dirname(os.path.dirname(FILE_DIR))
print('BASEDIR:' + BASEDIR)


# 使用类进行封装
class ReadJson(object):

    def __init__(self, filename):
        self.filepath = BASEDIR + "\\data\\" + filename

    def read_json(self):
        with open(self.filepath, "r", encoding="utf-8") as f:
            # 调用load方法加载文件流
            return json.load(f)

